package com.cf.main;

public class Application extends PrintArray implements Base {

	public static void main(String[] args) {
		// 训练集中有943个用户对1682个项目的评分
		int[][] user_movie_base = new ReadFile().readFile(BASE_DATA_COUNT, BASE_FILE);
		
		// 测试集中462个用户的实际评分
		int[][] test_matrix = new ReadFile().readFile(TEST_DATA_COUNT, TEST_FILE);
		
		//通过训练集的用户评分矩阵得到相似矩阵
		double[][] similarityMatrix = new ProduceSimilarityMatrix().produceSimilarityMatrix(user_movie_base);
		
		//根据相似矩阵获得评分矩阵
		double[][] predictMatrix = GetScore.getScore(user_movie_base, similarityMatrix);
		
		//计算准确度
		double[] maeArray = new ProduceMAE().produceMAE(predictMatrix, test_matrix);
		double maeSum = 0.0, MAE = 0.0;
		for (int k = 0; k < maeArray.length; k++) {
			maeSum += maeArray[k];
		}
		MAE = maeSum / TEST_DATA_COUNT;
		System.out.println("MAE=:" + MAE);
	}
	
	static boolean equal(double num1, double num2) {
		if ((num1 - num2 > -0.000001) && (num1 - num2) < 0.000001)
			return true;
		else
			return false;
	}

}
